// payerror.js
var shihan = require('../../common/fetch')
var config = require('../../common/config')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    showLoading: true
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) { //tradeno
    var that = this
    console.log(options.tradeno);
    shihan.sendRequest(config.pay_success, 'POST', {
        trade_no: options.tradeno
      })
      .then(function(response) {
        console.log(response);
        that.setData({
          bupiaoflag: options.bupiao,
          shopplist: response.data.data,
          paytrade: options.tradeno,
          showLoading: false
        })
      }, function(error) {
        console.log(error);
      });
  },
  lookorder: function() {
    if (this.data.shopplist.sh_is_join_text) {
      wx.redirectTo({
        url: '/pages/other/groupdetail/groupdetail?orderno=' + this.data.shopplist.sh_order_no,
      })
    } else {
      if (this.data.shopplist.sh_is_offline == 1) {
        wx.redirectTo({
          url: '/pages/myorder/myorder?orderindex=0',
        })
      } else {
        wx.redirectTo({
          url: '/pages/myorder/myorder?orderindex=2',
        })
      }
    }
  },
  goonbuy: function() {
    wx.switchTab({
      url: '/pages/home/home'
    })
  },
  viewgoodsDetail: function(e) {
    wx.navigateTo({
      url: '/pages/goodsdetail/goodsdetail?goodsid=' + e.currentTarget.dataset.id
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  }
})